Skip to content

Conversation

@pascalbaljet
Copy link
Member

This PR adds support for Flash Data. This allows you to send data to the frontend that isn't persisted in the browser history state. This makes it ideal for one-time notifications like toasts, highlights, or other transient UI states that shouldn't reappear when navigating back/forward.

You may use Inertia::flash() to flash data from the backend.

public function store(StoreUserRequest $request)
{
    $user = User::create($request->validated());

    Inertia::flash('toast', [
        'type' => 'success',
        'message' => 'User created successfully!',
    ]);

    return back();
}

You may chain back() on flash().

return Inertia::flash('newUserId', $user->id)->back();

Or chain flash() on render() and vice versa.

return Inertia::render('Projects/Index', [
    'projects' => $projects,
])->flash('highlight', $project->id);

// or...

return Inertia::flash()->render();

Flash Data is automatically reflashed on redirects, so it reaches the client after the redirect.

@pascalbaljet pascalbaljet merged commit c060177 into 2.x Dec 17, 2025
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants